home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pgp23src.zip / SRC / ZIP.C < prev    next >
C/C++ Source or Header  |  1993-05-09  |  1KB  |  43 lines

  1. /* Support code for the zip/unzip code - just handles error messages.  To
  2.    get exact errors, define ZIPDEBUG */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include "usuals.h"
  7. #include "fileio.h"
  8. #include "language.h"
  9. #include "pgp.h"
  10. #include "exitpgp.h"
  11.  
  12. #include "ziperr.h" /* for ZE_MEM (and errors[] if ZIPDEBUG defined) */
  13.  
  14. /* Clean error exit: c is a ZE_-class error, *msg is an error message.
  15.    Issue a message for the error, clean up files and memory, and exit */
  16.  
  17. void err(int c, char *msg)
  18.     {
  19.  
  20. #ifdef ZIPDEBUG
  21.     if (PERR(c))
  22.         perror("zip error");
  23.     fprintf(stderr, "zip error: %s (%s)\n", errors[c-1], msg);
  24. #endif /* ZIPDEBUG */
  25.  
  26.     /* Complain and return and out of memory error code */
  27.     if(c==ZE_MEM)
  28.     {    fprintf( stderr, PSTR("\nOut of memory\n") );
  29.         exitPGP( 7 );
  30.     }
  31.     else
  32.     {    fprintf( stderr, PSTR("\nCompression/decompression error\n") );    /* Yuck */
  33.         exitPGP( 23 );
  34.     }
  35.     }
  36.  
  37. /* Internal error, should never happen */
  38.  
  39. void error(char *msg)
  40.     {
  41.     err(-1, msg);
  42.     }
  43.